Skip to content

For pilot2 d#859

Merged
Barthelemy merged 2 commits into
AliceO2Group:masterfrom
lauraser:ForPilot2D
Oct 6, 2021
Merged

For pilot2 d#859
Barthelemy merged 2 commits into
AliceO2Group:masterfrom
lauraser:ForPilot2D

Conversation

@lauraser
Copy link
Copy Markdown
Contributor

@lauraser lauraser commented Oct 4, 2021

The following check takes a canvas as input, loops over all figures containing IROCs and OROCs in the canvas and checks for empty pads.
Besides storing the main quality object, it has private member to store qualities for every histogram which are later used in beautify to show specific quality for every histogram instead of the entire canvas.
@wiechula Stefan suggested the limits for medium quality 30% of pads empty and for bad 60% of pads empty. Do you think this is reasonable?

@lauraser lauraser requested a review from wiechula as a code owner October 4, 2021 17:50
@Barthelemy
Copy link
Copy Markdown
Collaborator

I let @wiechula review this PR.

Copy link
Copy Markdown
Collaborator

@wiechula wiechula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lauraser , thanks for the code.
I have many small comments to improve code readability mainly. For the future, in general, please always

  • use const whenever possible
  • always use readability braces

Comment on lines +52 to +57
if (titleh.find("IROC") != std::string::npos)
iroc = true;
if (titleh.find("OROC") != std::string::npos)
oroc = true;
if (!(iroc || oroc))
return Quality::Null;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add readability braces and simplify expression (assuming it cannot be both, IROC and OROC). Also, the IROC / OROC distinction is only used to get the total number of pads.

Suggested change
if (titleh.find("IROC") != std::string::npos)
iroc = true;
if (titleh.find("OROC") != std::string::npos)
oroc = true;
if (!(iroc || oroc))
return Quality::Null;
int totalPads = 0;
if (titleh.find("IROC") != std::string::npos) {
totalPads = 5280;
} else if (titleh.find("OROC") != std::string::npos) {
totalPads = 9280;
} else {
return Quality::Null;
}

Comment on lines +44 to +45
auto padName = fmt::format("c_ROCs_Pedestal_2D_{:d}", tpads);
auto histName = fmt::format("h_Pedestals_ROC_{:02d}", tpads - 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto padName = fmt::format("c_ROCs_Pedestal_2D_{:d}", tpads);
auto histName = fmt::format("h_Pedestals_ROC_{:02d}", tpads - 1);
const auto padName = fmt::format("c_ROCs_Pedestal_2D_{:d}", tpads);
const auto histName = fmt::format("h_Pedestals_ROC_{:02d}", tpads - 1);

Quality result = Quality::Null;
if (mo->getName() == "c_ROCs_Pedestal_2D") {
result = Quality::Good;
auto* canv = dynamic_cast<TCanvas*>(mo->getObject());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dynamic cast only makes sense if you want the verify the object type. So I guess you should either change this to static_cast of c-style cast (TCanvas*) or add

if (!canv) {
  return Quality::Null;
}

auto histName = fmt::format("h_Pedestals_ROC_{:02d}", tpads - 1);
TPad* pad = (TPad*)canv->GetListOfPrimitives()->FindObject(padName.data());
TH2F* h = (TH2F*)pad->GetListOfPrimitives()->FindObject(histName.data());
std::string titleh = h->GetTitle();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::string titleh = h->GetTitle();
const std::string titleh = h->GetTitle();

Comment on lines +62 to +53
int totalPads = 0;
if (iroc)
totalPads = 5280;
if (oroc)
totalPads = 9280;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, see above.

Suggested change
int totalPads = 0;
if (iroc)
totalPads = 5280;
if (oroc)
totalPads = 9280;

Comment on lines +108 to +109
auto padName = fmt::format("c_ROCs_Pedestal_2D_{:d}", tpads);
auto histName = fmt::format("h_Pedestals_ROC_{:02d}", tpads - 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto padName = fmt::format("c_ROCs_Pedestal_2D_{:d}", tpads);
auto histName = fmt::format("h_Pedestals_ROC_{:02d}", tpads - 1);
const auto padName = fmt::format("c_ROCs_Pedestal_2D_{:d}", tpads);
const auto histName = fmt::format("h_Pedestals_ROC_{:02d}", tpads - 1);

TPad* pad = (TPad*)canv->GetListOfPrimitives()->FindObject(padName.data());
pad->cd();
TH2F* h = (TH2F*)pad->GetListOfPrimitives()->FindObject(histName.data());
std::string titleh = h->GetTitle();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::string titleh = h->GetTitle();
const std::string titleh = h->GetTitle();

if (it != badSectorsName.end()) {
TPaveText* msg = new TPaveText(0.1, 0.9, 0.9, 0.95, "NDC");
msg->SetBorderSize(1);
int index = std::distance(badSectorsName.begin(), it);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int index = std::distance(badSectorsName.begin(), it);
const int index = std::distance(badSectorsName.begin(), it);

pad->cd();
TH2F* h = (TH2F*)pad->GetListOfPrimitives()->FindObject(histName.data());
std::string titleh = h->GetTitle();
std::vector<std::string>::iterator it = std::find(badSectorsName.begin(), badSectorsName.end(), titleh);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<std::string>::iterator it = std::find(badSectorsName.begin(), badSectorsName.end(), titleh);
auto it = std::find(badSectorsName.begin(), badSectorsName.end(), titleh);

TH2F* h = (TH2F*)pad->GetListOfPrimitives()->FindObject(histName.data());
std::string titleh = h->GetTitle();
std::vector<std::string>::iterator it = std::find(badSectorsName.begin(), badSectorsName.end(), titleh);
if (it != badSectorsName.end()) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change logic to make clear that the reader does not have to continue reading the code:

Suggested change
if (it != badSectorsName.end()) {
if (it == badSectorsName.end()) {
continue
}

@lauraser lauraser force-pushed the ForPilot2D branch 2 times, most recently from e3ca053 to 9a71874 Compare October 5, 2021 20:30
@Barthelemy
Copy link
Copy Markdown
Collaborator

error unrelated, merging

@wiechula
Copy link
Copy Markdown
Collaborator

wiechula commented Oct 6, 2021

@Barthelemy , seem it is not merged.

@Barthelemy Barthelemy merged commit 2cf5594 into AliceO2Group:master Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants